//
//  SWSSORegisterReq.swift
//  ChildStory
//
//  Created by linhan on 16/8/18.
//  Copyright © 2016年 Aiya. All rights reserved.
//

import Foundation
import Foundation
class SWSSORegisterReq: SWBaseRequest
{
    var connectionAccount:SWConnectionAccount?
    var platform:ConnectionPlatform = ConnectionPlatform.Default
    
    override init()
    {
        super.init()
        options.authorize = false
        //api = SWRequestAPI.SSORegister
    }
    
    override var params:Any?
    {
        guard let account = connectionAccount else{
            return nil
        }
        var param:[String:Any] = [:]
        param["ouid"] = account.unionID ?? ""
        param["channel"] = platform.rawValue
        param["expires_in"] = 3600
        param["access_token"] = account.token?.token ?? ""
        param["avatar"] = account.avatarURL ?? ""
        param["nickname"] = account.screenName ?? ""
        param["gender"] = account.gender.responseValue
        return param
    }
    
    override func JSONToModel(_ json:JSON, JSONString:String, JSONData:Data) -> AnyObject?
    {
        return Mapper<SWSSORegisterRsp>().map(JSONString: JSONString)
    }
    
}

class SWSSORegisterRsp: NSObject,Mappable
{
    var code:Int?
    var data:SWAuthDataRsp?
    
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        code    <- map["code"]
        data    <- map["data"]
    }
}
